﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;
using Logic.BusinessLogic;

public partial class Pages_Dashboard_MasterAccount_PostStatus : System.Web.UI.Page, ICrumbedPage
{

	public int ProfileAccountID
	{
		get
		{
			int temp;
			int.TryParse(Request["ID"], out temp);
			return temp;
		}
	}
	protected BO.User User;
	private void Authenicate()
	{
		if (Authentication.IsCurrentUserAuthenticated())
			User = Authentication.GetCurrentUser();

		if (User == null)
			Response.Redirect("/default.aspx");
	}

    protected void Page_Load(object sender, EventArgs e)
    {
		Authenicate();
		var pAccount = BLL.Profiles.GetByID(ProfileAccountID);
		
		lblAccountNam.Text = pAccount.Name;
		LoadData();
    }

	private void LoadData()
	{
		postStatus.User = User;

        ucProfileSideMenu.User = User;

		postStatus.OptionalMasterAccounts = AccountService.GetMasterAccountsForProfile(ProfileAccountID);
		

		if (!IsPostBack)
		{
			var posts = Logic.BusinessLogic.Stats.GetPostsByProfileAccountID(ProfileAccountID, BO.Post.PostTypes.StatusLine);
			repPosts.DataSource = posts;
			repPosts.DataBind();
		}
	}

	#region ICrumbedPage Members

	public int Level
	{
		get { return 3; }
	}

	public string TailName
	{
		get { return Resources.Texts.Post_status_line; }
	}

	#endregion
}